<?php
include('act.php');
?>
<?php 
//Do we have an authcookie?
if(isset($_COOKIE['authcookie']))
 { 
 //Why, yes we do! Lets keep it for later.
 $authcookie = $_COOKIE['authcookie']; 
 $uname = $_COOKIE['account'];

 } 
 else 
 { 
 //Aww, no cookie for you? Lets attempt to get you one :D
 $p = "login";
 } 

if (!isset($p)) {
	if (!isset($_GET['p'])) {
		$p = "home"; // Default page
	} else {
		$p = $_GET['p'];
	}
}
if(isset($_POST['logout'])) {
setcookie("account", "", time()-3600);
setcookie("authcookie", "", time()-3600);
$controlmsg = new xmlrpcmsg('atheme.logout');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				
die("<br /><a href=\"index.php?p=login\">Login Again</a>");
}


?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHPAtheme by giod - <?php echo $p ?></title>
<link href="style.css" rel="stylesheet" type="text/css"/>
<script language="javascript"> 
<!--
var state = 'none';

function showhide(layer_ref) {

if (state == 'block') { 
state = 'none'; 
} 
else { 
state = 'block'; 
} 
if (document.all) { //IS IE 4 or 5 (or 6 beta) 
eval( "document.all." + layer_ref + ".style.display = state"); 
} 
if (document.layers) { //IS NETSCAPE 4 or below 
document.layers[layer_ref].display = state; 
} 
if (document.getElementById &&!document.all) { 
hza = document.getElementById(layer_ref); 
hza.style.display = state; 
} 
} 
//--> 
</script> 

</head>

<body>
<div id="container">
<!-- header -->
<div id="header">

<div id="logo"><a href="index.php"><img src="images/PHPAtheme.png"/></a></div>

<div id="slogan">Manage your Atheme services account from the web!</div>

</div>

<div id="header_menu"><a href="index.php?p=home">Home</a> &nbsp; | &nbsp; <a href="index.php?p=nick">NickServ</a> &nbsp; | &nbsp; <a href="index.php?p=chan">ChanServ</a> &nbsp; | &nbsp; <a href="index.php?p=memo">MemoServ</a></div>

<!--end header -->
<!-- main -->
<div id="main">

<div id="sidebar" style="word-wrap: break-word">
<?php include('sidebar.php') ?>
</div>

<div id="text">
<!-- begin content -->
<?php if (isset($_POST['infochan']) || isset($_POST['flistchan']) || isset($_POST['memlist']) || isset($_POST['readnum'])){ echo "<pre>"; } ?>
<?php

include ("content/".$p.".php");

?>

<!-- end content -->
</div>

</div>
<!-- end main -->
<!-- footer -->
<div id="footer_menu"><a href="index.php?p=home">Home</a> &nbsp; | &nbsp; <a href="index.php?p=nick">NickServ</a> &nbsp; | &nbsp; <a href="index.php?p=chan">ChanServ</a> &nbsp; | &nbsp; <a href="index.php?p=memo">MemoServ</a></div>

<div id="footer">
Powered by <a href="http://phpatheme.collinnet.us/" target="_BLANK">PHPAtheme</a>.
</div>
<!-- end footer -->
</div>
</body>
</html>